'use strict';
const appId = ''
const secret = ''
exports.main = async (event, context) => {
	//event为客户端上传的参数
	console.log('event : ', event)
	let url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=' + appId +
		'&secret=' + secret;
	const res = await uniCloud.httpclient.request(url, {
		method: 'GET',
		data: {},
		dataType: 'json'
	})
	console.log(res)
	let imgUrl = 'https://api.weixin.qq.com/wxa/getwxacode?access_token=' + res.data.access_token;
	const resImg = await uniCloud.httpclient.request(imgUrl, {
		method: 'POST',
		headers: {
			'Content-Type': 'application/json'
		},
		data: {
			'path': 'pages/index/index'
		},
	})
	console.log(resImg)
	//返回数据给客户端
	return resImg.data
};
